<?php

class Ecard_Form_Admin_Image_Create extends Engine_Form
{
  public function init()
  {
      $this->clearDecorators()
//      ->addDecorator('FormElements')
//      ->addDecorator('Form')
      ->setAction(Zend_Controller_Front::getInstance()->getRouter()->assemble(array()));

        $this->setTitle('Create Image');
        
        $categoryTB = Engine_Api::_()->getDbTable('categories','ecard');
        $categories = $categoryTB->fetchAll($categoryTB->select());  
        $category_prepare = array();
        foreach($categories as $category){
            $category_prepare[$category->category_id] = $category->category_name;
        }  
        

        $this->addElement('text','title',array(
            'label'=>'Title',
			'required' =>true,
            'allowEmtry'=>false,
            'validators' => array (
					array (
						'NotEmpty', 
						true
					)
			)                                             
        ));

        $this->addElement('Select', 'category_id', array(
	        'label' => 'Category',
	        'multiOptions' => $category_prepare,
        ));
             
		$this->addElement('File', 'image_upload', 
			array (
				'label' => 'Add Image', 
				'destination' => APPLICATION_PATH . '/public/temporary/', 
				'multiFile' => 1, 
				'validators' => array (
					array (
						'Extension', 
						false, 
						'jpg,jpeg,png,gif'
					)
				),
                'required' =>true,
                'allowEmtry'=>false     
			)
		); 
        
       $this->addElement('Hidden', 'file_id', array('order' => 100));  
       $this->addElement('Hidden', 'comp_id', array('order' => 101));
       $this->addElement('Hidden', 'file_url', array('order' => 102));  
       
       
       
       
       $this->addElement('Button', 'submit', array (
			'label' => 'Submit', 
			'type' => 'submit',
			'decorators' => array (
				'ViewHelper'
			)
		)); 
       
		$this->addElement('Cancel', 'cancel', array (
				'label' => 'cancel', 
				'link' => true, 
				'href' => '', 
                'onclick' => 'cancelCreate();',
				'decorators' => array (
						'ViewHelper'
				)
		));               

		$this->addDisplayGroup(
			array (
				'submit', 
				'cancel'
			), 'buttons', array ()
		);            
  }
}  